package api

import (
	"CodeCover/internal/db"
	"CodeCover/internal/handler"
	"CodeCover/internal/respository"
	"CodeCover/internal/service"

	"github.com/gin-gonic/gin"
)

func TaskRoute(r *gin.Engine) {
	sqlTaskRepo := respository.NewMysqlTaskRepository(db.SqlDB)
	taskSvc := service.NewTaskService(sqlTaskRepo)
	taskHandler := handler.NewTaskHandler(taskSvc)

	// "tasks/${username}"
	// "tasks/${username}/${tid}"

	taskGroup := r.Group("/tasks")
	{

		taskGroup.POST("", taskHandler.GetTasks)

		taskGroup.GET("/task/:tid", taskHandler.GetOneTask)
		taskGroup.GET("/dirdata/:tid", taskHandler.GetDirJson)
		taskGroup.GET("/file", taskHandler.GetFile)
	}

	// r.GET("/tasks/:username", func(ctx *gin.Context) {
	// })

}
